const os = require('os');
const fs = require('fs');
const log4js = require('log4js');

log4js.configure({
	appenders: { file: { type: 'file', filename: 'instguide.log' } },
	categories: { default: { appenders: ['file'], level: 'info' } }
});

// 获取用户目录
const userHome = os.homedir();
// 创建日志目录
const logDirectory = `${userHome}/.config/Kylin-Code/installconfig/log`;
fs.mkdirSync(logDirectory, { recursive: true }); // 递归创建目录

log4js.configure({
	appenders: {
		file: {
			type: 'file',
			filename: `${logDirectory}/instguide.log`
		}
	},
	categories: {
		default: { appenders: ['file'], level: 'info' }
	}
});

const logger = log4js.getLogger();

// logger.info('这是一条信息日志');
// logger.error('这是一个错误日志');
module.exports = logger;
